import { theRecentVaction } from './recentvaction'
import { daystamp, today, passWeekOfMonth, passWeekOfYear } from './today'

/**
 * 最近带有假期的节日
 * @returns 
 */
 function recentVaction(){
  const rightVaction = theRecentVaction()
  const bodys = rightVaction.gap ? [
    ""+(rightVaction.gap),
    rightVaction.name,
    rightVaction.count+'天假期',
  ] : [
    rightVaction.name,
    rightVaction.count+'天假期中'
  ]
  return {
    itemClass: 'date-func number festival'+`${rightVaction.gap ? '': ' in-days'}`,
    body: bodys
  }
}


/**
 * 显示今日详情的蓝色卡片
 * @returns 
 */
export function blueCards({ today }){
  const lunarDate = today.lunarDate
  const items =  [
    {
      body: [
        today.month+'',
        today.day+'',
      ],
      itemClass: 'date-func func-today'
    },

    recentVaction(),

    {
      body: [
        lunarDate.ncWeek,
        '第'+passWeekOfYear+'周'
      ],
      itemClass: 'date-func func-main func-week'
    },
    {
      body: [
        lunarDate.astro,
        today.month+'/'+today.day
      ],
      itemClass: 'date-func func-main func-astro'
    },
    {
      body: [
        lunarDate.gzYear+'「'+lunarDate.Animal+'」',
        lunarDate.IMonthCn+lunarDate.IDayCn

      ],
      itemClass: 'date-func func-main func-year'
    },
  ]

  // Term 节气
  // festival 阳历节日
  // lunarFestival  农历节日
  let {Term, festival, lunarFestival} = lunarDate
  if (lunarFestival) {
    if (lunarFestival.length === 2) {
      lunarFestival = '过' + lunarFestival
    }
    items.push({
      body: [
        lunarFestival,
        `${lunarDate.IMonthCn}/${lunarDate.IDayCn}`
      ],
      itemClass: 'date-func func-main func-festival'
    })
  }

  if (festival) {
    items.push({
      body: [
        festival,
        `${today.month}/${today.day}`
      ],
      itemClass: 'date-func func-main func-festival'
    })
  }

  if (Term) {
    if (Term.length === 2) {
      Term = Term + '节气'
    }
    items.splice(1, 0, {
      body: [
        Term,
        `${today.month}/${today.day}`
      ],
      itemClass: 'date-func func-main func-festival'
    })
  }
  
  return items
}